import {
  order_plan_query
} from '../../../api/shipping'
const util = require('../../../utils/util.js')
Page({

  data: {
    axis:[]
  },

  onLoad: function (options) {
    this.loadList(options)
  },

  loadList(data) {
    var _this = this
    order_plan_query({ orderId: data.orderid, productId: data.productid }).then(res => {
      if (res.type == 'success') {
        _this.data.axis = res.data
        _this.data.axis.forEach(function(item){
          item.planDate = util.datetimeFormat(item.planDate)
          if(item.status == 0){
            item.statusTitle = '待配送'
          }else if (item.status == 1){
            item.statusTitle = '配送中'
          }else{
            item.statusTitle = '已完成'
          }
        })
        _this.setData({
          axis: _this.data.axis
        })
      }
    }).catch(error => {
      wx.showToast({
        icon: "none",
        title: error.content,
      })
    })
  }
})
